﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace CodeGen.TS
{
    class Program
    {



        static void Main(string[] args)
        {
            if (Properties.Settings.Default.IndentString == "\\t")
                Properties.Settings.Default.IndentString = "\t";
            Input.ParameterParser parser = new Input.ParameterParser();
            string fileName = parser.ParseArgumentValue("FileName");
            bool useConfig = parser.ContainsArgument("xmlconfig");
            if (useConfig)
            {
                string xmlConfigFile = parser.ParseArgumentValue("xmlconfig");
                Input.ConfigParser cfparser = new Input.ConfigParser(fileName, xmlConfigFile);
                cfparser.Execute();
            }
            else
            {
                if (fileName == null)
                {
                    ShowHelp();
                }
                else
                {
                    Input.ParameterUsage.UseParameters(fileName, parser);
                }
            }

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
                Console.ReadLine();
#endif
        }
        static void ShowHelp()
        {
            Console.WriteLine("You can use the following arguments:");
            Console.WriteLine("/FileName\tSpecifies which dll should be used to generate Typescript Code. This parameter is required if you do not use /XmlConfig");
            Console.WriteLine("/XmlConfig\tIf you do not want to generate code by using the commandline, you can specify an xml file with complexer configurations. " +
                "For an example of such a file see in Source\\Sample\\outputConfig.xml. The XML Schema is found in Source\\Input\\XMLConfig.xsd");
            Console.WriteLine("/GenerateClass\tGenerate a class instead of an interface");
            Console.WriteLine("/UseObservable\tUse KnockoutJS-Observables for the fields");
            Console.WriteLine("/UseInitalValue\tUse an inital value foreach generated Field");
            Console.WriteLine("/Output\tFile to output the code");
            Console.WriteLine("/GeneratedWebServiceMethod\tGenerate a method that sets all fields with values from a parameter");
            Console.WriteLine("/Types\tThe CLR Types to generate code from. You can specify multiple values by separating them with commas. ");
        }


    }
}
